//
//  YWPublicBaseViewController.m
//  YWBaseFrameWork
//
//  Created by mac on 16/7/16.
//  Copyright © 2016年 NeiQuan. All rights reserved.
//

#import "YWPublicBaseViewController.h"
#import "YWUIKitHeader.h"
@interface YWPublicBaseViewController ()
{
    
    
}
@end
@implementation YWPublicBaseViewController
- (void) dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    if ([UIDevice currentDevice].systemVersion.floatValue >= 7)
    {
        self.edgesForExtendedLayout = UIRectEdgeNone;
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    [self addContentView];
}
- (NSInteger)tabBarHeight
{
    return self.hasTabBar ? 49 : 0;
}
- (void)addContentView
{
    NSInteger tabBarHeight = [self tabBarHeight];
    CGRect frame = CGRectZero;
    if (self.navigationBarHidden)
    {
        frame = CGRectMake(0, 0, self.view.width, self.view.height - tabBarHeight);
    }
    else
    {
        if ([UIDevice currentDevice].systemVersion.floatValue >= 7)
        {
            frame = CGRectMake(0, 64, self.view.width, self.view.height -64- tabBarHeight);
        }else
        {
            frame = CGRectMake(0, 44, self.view.width, self.view.height -44- tabBarHeight);
        }
        
    }
    
    //self.contentView = [[UIView alloc] initWithFrame:frame];
   // self.contentView.backgroundColor =[UIColor  whiteColor];;
    self.view.backgroundColor =[ UIColor whiteColor];
    //contentView第一个放在self.view上,会导致contentView上的tableView contentInset发生变化.
    self.wrapperView = [[UIView alloc] initWithFrame:self.view.bounds];
   // [self.view addSubview:_wrapperView];
    //[self.view addSubview:self.contentView];
}
#pragma mark - /** 设置导航条右边按钮 */
/** 既有图标又有文字的左边按钮 */
-(void)setRightBarButtonItemWithFrame:(CGRect)frame title:(NSString *)titile titleColor:(UIColor *)titleColor image:(NSString *)image imageInsets:(UIEdgeInsets)insets backImage:(NSString *)backImage selectBackImage:(NSString *)selectBackImage action:(SEL)action{
    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
    rightButton.frame = frame;
    [rightButton setTitle:titile forState:UIControlStateNormal];
    [rightButton setTitleColor:titleColor forState:UIControlStateNormal];
    [rightButton setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    rightButton.imageEdgeInsets = insets;
    [rightButton setBackgroundImage:[UIImage imageNamed:backImage] forState:UIControlStateNormal];
    [rightButton setBackgroundImage:[UIImage imageNamed:selectBackImage] forState:UIControlStateHighlighted];
    rightButton.titleLabel.font = [UIFont boldSystemFontOfSize:13];
    UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
    self.navigationItem.rightBarButtonItem = rightBarButtonItem;
}
/** 只有图片的右边按钮 */
-(void)setRightBarButtonWithImage:(NSString *)imageName action:(SEL)action{
    
    UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:imageName] style:UIBarButtonItemStylePlain target:self action:action];
    
    self.navigationItem.rightBarButtonItem = rightBarButtonItem;
    
}
/** 只有图片的右边按钮 */
-(void)setRightBarButtonWithTitle:(NSString *)title action:(SEL)action{
    
    UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain target:self action:action];
    self.navigationItem.rightBarButtonItem = rightBarButtonItem;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}


@end
